<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!-- jqgrid-->
<link
	href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css"
	rel="stylesheet" />
<!doctype html>
<head>
</head>
<html>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;参数设置>节假日登记</span>
		</div>
		<div class="ibox-content">
			<div role="form" class="form-inline">
				<div class="form-group">
					<input id="dateH" name="submitTimeEnd" placeholder="查询时间"
						class="laydate-icon form-control">
				</div>
				<button class="zhixcx" type="button" onclick="query();">执行查询</button>
				<button class="zhixcx" type="button" onclick="save();">初始化节假日日期</button>
				<!--                    <button class="zhixcx" type="button" onclick="sss();">查询多个日期</button> -->
				<!--                    <button class="zhixcx" type="button" onclick="ttt();">查询多个日期</button> -->
			</div>
		</div>
		<div class="ibox-content">
			<div class="jqGrid_wrapper">
				<table id="table_list_1"></table>
				<div id="pager_list_1"></div>
			</div>
		</div>
	</div>
	<div id="zcszjl" style="display: none;">
		<div class="padding-nono">
			<table cellpadding="0" cellspacing="0" border="0"
				class="buyinfor-table">
				<tr>
					<td align="right"><label class="control-label np">日期：</label>
					</td>
					<td><input id="id" type="hidden" class="form-control" /> <input
						id="dateHH" type="text" class="form-control" readonly="readonly" />
					</td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">日期类型：</label>
					</td>
					<td><select id="dateTypes" class="select-control">
							<option value="1">工作日</option>
							<option value="2">周末</option>
							<option value="3">节假日</option>
					</select></td>
				</tr>
			</table>
			</div>
			<div class="padding-nono">
			<table cellpadding="0" cellspacing="0" border="0"
				bordercolor="#3B95C8" width="100%">
				<tr>
					<td width="100%" align="center">
						<div class="ibox-content">
							<button class="btn dpbtn_blue" type="button" onclick="update();">提交</button>
							<button class="btn dpbtn_red" type="button" onclick="cancel();">取消</button>
						</div>
					</td>
				</tr>
			</table>
		</div>
	</div>

	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>

	<!-- jqGrid -->
	<script type="text/javascript" charset="utf-8"
		src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>

	<!-- layerDate plugin javascript -->
	<script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>


	<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
	    
	    var winWidth = $(window).width();
		var winHeight = $(window).height();
		
	    jQuery(function($) {  
		    laydate({
		        elem: '#dateH', 
		        event: 'focus' 
		    });
	    	getData();
	    });
	    
	    var layerout;
	    var getData = function()
	    {
	  var winWidth = $('div.ibox-content').width();
	        var winHeight = document.body.offsetHeight - 300;
	     	var win = winWidth / 7 - 20;
  	 	   $.jgrid.defaults.styleUI = 'Bootstrap';
  	 	   var data={};
  	 	   data.orderSql="date_h desc";
		  jQuery("#table_list_1").jqGrid({
			url:'${basePath}/OtherHolidaysController/selectByExt',
	        datatype : "json",
	        postData:data,
	        colNames : [ '编号', '日期','日期类型',''],
	        colModel : [ 
	                     {name: 'replaceId', index: 'id',width: win,align: "center"},
	            		 {name: 'dateH',index: 'dateH',width: win,align: "center"},
	            		 {name: 'dateTypeDisplay',index: 'dateType',width: win,align: "center"},
	            		 {name: 'dateType',index: 'dateType',hidden:true}
	                   ],
              mtype : "post",
              height: winHeight,
              width:winWidth,  
              autowidth: true,
              shrinkToFit: true,
              rowNum: 15,
              rowList: [15, 30, 45],
              viewrecords: true,
              pager: "#pager_list_1",
              hidegrid: false,
              multiselect : false,
              altRows:true,
              altclass:'someClass',
              ondblClickRow:function(rowId,v,e)
              {	  
            	  
            	  layerout=layer.open({
	    		    	  type: 1,
	    		    	  title: '修改日期类型',
	    		    	  shadeClose: true,
	    		    	  shade: 0.8,
	    		    	  area: ['300px', '350px'],
	    		    	  content: $("#zcszjl"),
	    	      });  	 
            	  var rowData = $("#table_list_1").jqGrid("getRowData", rowId);
            	  var id = rowData.replaceId;
            	  var dateH=rowData.dateH;
            	  var dateTypeDisplay=rowData.dateTypeDisplay; 
            	  var dateType=rowData.dateType;
            	  $("#dateHH").val(dateH);
            	  $("#id").val(id);
                  var t1 = document.getElementById("dateTypes");   
	      	        for(i=0;i<t1.length;i++){//给select赋值  
	      	            if(dateType==t1.options[i].value){  
	      	                t1.options[i].selected=true  
	      	            }  
	      	        }
              },
              jsonReader : {
            	  root:"result.rows",
            	  page: "result.page",
            	  total: "result.total",
            	  records: "result.records",
            	  repeatitems: false,
            	  id: "replaceId"
              },
              loadComplete:function(datas){
            	  if (datas.flag == "100100") {
                      layer.msg("查询成功!", {icon: 6, time: 1000});
                      return;
                  }
            	  if(datas.flag == '100802') {
    				  top.location.href = thisLoginUrl;
    				  return;
    			  }

            	  layer.msg(datas.message, {icon: 2});
              }
	      });
	    }	    
	    var save=function(){
	    	$.dpAjax({
	    		url:'${basePath}/OtherHolidaysController/insert',
    			success: function(datas){
	    			  if(datas.flag == "100100")
					  {
	    				  layer.msg('执行成功！', {icon: 6});
	    				  jQuery("#table_list_1").trigger("reloadGrid");
						  return;
					  }
					  if(datas.flag == "100200")
	                  {
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
                 }
	    	});
	    }
	    var update=function(){
	    	var data={};
	    	data.id=$("#id").val();
	    	data.dateType=$('#dateTypes option:selected').val();
	    	$.dpAjax({
	    		url:'${basePath}/OtherHolidaysController/update',
	    		data:data,
    			success: function(datas){
	    			  if(datas.flag == "100100")
					  {
	    				  layer.close(layerout);
	    				  jQuery("#table_list_1").trigger("reloadGrid");
						  return;
					  }
					  if(datas.flag == "100200")
	                  {
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
                 }
	    	});
	    }
	    var cancel=function(){
	    	layer.closeAll();
	    }
	    window.onresize = function()
	    {
	    	$("#table_list_1").setGridWidth($(window).width()-80);
	    }
	    
	    var query = function(dayEnum)
	    {
	    	var postData = $("#table_list_1").jqGrid("getGridParam", "postData");
	    	var data = {};
	    	data.dateH=$("#dateH").val();
	    	$.extend(postData, data);
	    	refresh();
	    }
	    
	    var refresh = function()
	    {
	    	$("#table_list_1").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
	    }
	    var ttt=function(){
	    	var data={};
	    	data.dateType="1";
	    	data.num=7;
	    	data.dateNH="2018-12-20";
	    	data.orderSql="date_h asc";
	    	$.dpAjax({
	    		url:'${basePath}/OtherHolidaysController/getNextWorkDay',
	    		data:data,
    			success: function(datas){
	    			  if(datas.flag == "100100")
					  {
	    				  layer.msg('执行成功！', {icon: 6});
	    				  jQuery("#table_list_1").trigger("reloadGrid");
						  return;
					  }
					  if(datas.flag == "100200")
	                  {
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
                 }
	    	});
	    }
	    var sss=function(){
	    	var data={};
	    	data.dateH="2018-12-20";
	    	$.dpAjax({
	    		url:'${basePath}/OtherHolidaysController/findDateTypeList',
	    		data:data,
    			success: function(datas){
	    			  if(datas.flag == "100100")
					  {
	    				  layer.msg('执行成功！', {icon: 6});
	    				  jQuery("#table_list_1").trigger("reloadGrid");
						  return;
					  }
					  if(datas.flag == "100200")
	                  {
						  $.fn.showDatas({"datas":datas});
	                	  return;
	                  }
                 }
	    	});
	    }
    </script>
</body>
</html>
